Xceed DataGrid for WPF v7.2 Documentation
Formatting a Cell's Content

The following example demonstrates how to format a cell's content to display a numeric value as a currency value. Although it might be tempting to apply the converter to a column's DisplayMemberBindingInfo, this is not the recommended location as not only will the cells' content be formatted but the data type of the cells' content will be changed to the converter's.

XAML
Copy Code
<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"

      xmlns:local="clr-namespace:Xceed.Wpf.Documentation">

  <Grid.Resources>

    <xcdg:DataGridCollectionViewSource x:Key="cvs_orderdetails"

                                    Source="{Binding Source={x:Static Application.Current},

                                                      Path=OrderDetails}"/>          

          

    <xcdg:CurrencyConverter x:Key="currencyConverter"/>

    <DataTemplate x:Key="currency_celltemplate">

      <TextBlock Text="{Binding Converter={StaticResource currencyConverter}}"/>

    </DataTemplate>

  </Grid.Resources>

  <xcdg:DataGridControl x:Name="OrderDetailGrid"

                        ItemsSource="{Binding Source={StaticResource cvs_orderdetails}}">

    <xcdg:DataGridControl.Columns>

      <xcdg:Column FieldName="UnitPrice"

                   CellContentTemplate="{StaticResource currency_celltemplate}"/>

    </xcdg:DataGridControl.Columns>

  </xcdg:DataGridControl>

</Grid>